#—*—coding:utf-8 -*-
#@Time        :2022/7/15 20:50
#@Author      :dhx
#@File        :login_page.py
# @Software: PyCharm
from selenium.webdriver.common.by import By
from pages.base_pageage import BasePage
from config.config import HOST
class LoginPage(BasePage):
    """登陆页面类"""
    url="http://192.168.1.120/crm"
    username_locator=(By.NAME,'name')
    password_locator = (By.NAME,'password')
    login_btn_locator=(By.NAME,'submit')
    def input_username(self,username):
        """输入用户名"""
        self.driver.find_element(*self.username_locator).send_keys(username)
    def input_password(self,password):
        """输入密码"""
        self.driver.find_element(*self.password_locator).send_keys(password)

    def click_login(self):
        """输入密码"""
        self.driver.find_element(*self.login_btn_locator).click()

    def login_crm(self,username,password):
        """登录首页"""
        element = BasePage(self.driver)
        element.find(self.username_locator).send_keys(username)
        element.find(self.password_locator).send_keys(password)
        element.find(self.login_btn_locator).click()

    def switch_goods_page(self,url):
        """在首页切换到产品页"""
        self.driver.get(url)